package com.young.springdemo.service.visitorpattern;

//财务部门充当具体访问者
public class FADepartment extends Department {
    @Override
    public void visit(FulltimeEmployee fulltimeEmployee) {
        //正式员工 周薪+加班(-请假)
        double workHours = fulltimeEmployee.getWorkHours();
        if (workHours > 40) {
            System.out.println("正式员工" + fulltimeEmployee.getName() + "实际工资:" + (fulltimeEmployee.getWeekWage() +
                    (workHours - 40) * 100) + " 元");
        } else {
            double weekSalary = fulltimeEmployee.getWeekWage() - (40 - workHours) * 80;
            weekSalary = weekSalary > 0 ? weekSalary : 0;
            System.out.println("正式员工" + fulltimeEmployee.getName() + "实际工资" + weekSalary + " 元");
        }
    }

    @Override
    public void visit(ParttimeEmployee parttimeEmployee) {
        System.out.println("临时员工" + parttimeEmployee.getName() + "实际工资" + parttimeEmployee.getWorkHour() *
                parttimeEmployee.getHourWage() + " 元");
    }
}
